home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / bindings / emacs-fun / term.awk < prev   
Encoding:
AWK Script  |  1996-09-27  |  2.7 KB  |  112 lines

  1. BEGIN {
  2.    terminal_leader["\n\n"]=""
  3.    #{{{}}}
  4. #   {{{  mark used keys
  5.    used["left"]=1
  6.    used["right"]=1
  7.    used["up"]=1
  8.    used["down"]=1
  9.    used["prev_page"]=1
  10.    used["next_page"]=1
  11.    used["rubout"]=1
  12.    used["backspace"]=1
  13.    used["home"]=1
  14.    used["begin"]=1
  15.    used["end"]=1
  16.    used["delline"]=1
  17.    used["clreol"]=1
  18.    used["suspend"]=1
  19.    used["open"]=1
  20.    used["close"]=1
  21.    used["command"]=1
  22.    used["shift-command"]=1
  23.    used["exit"]=1
  24.    used["shift-exit"]=1
  25.    used["save"]=1
  26.    used["select"]=1
  27.    used["shift-help"]=1
  28.    used["help"]=1
  29.    used["refresh"]=1
  30. #   }}}
  31. }
  32. #{{{  starting a terminal
  33. /^\(terminal \([^ ]+\) *$/ {
  34.    current_term=substr($2,2,length($2)-2)
  35.    if (used[current_term]) {
  36.       print("ignoring duplicate terminal ("current_term").")
  37.       current_term=""
  38.    } else
  39.       used[current_term]=1
  40.    term_data=""
  41.    next
  42. }
  43. #}}}
  44. #{{{  end a terminal
  45. /^\) *$/ {
  46.    term_data="\n"term_data"\n"
  47.    if (terminal_leader[term_data]=="")
  48.       terminal_leader[term_data]=current_term
  49.    else
  50.       terminal_group[term_data]=terminal_group[term_data]" "current_term
  51.    current_term=""
  52.    next
  53. }
  54. #}}}
  55. #{{{  skip lines outside of terminals
  56. current_term=="" {
  57.    next
  58. }
  59. #}}}
  60. #{{{  skip invalid or unused aliases
  61. { critical="" }
  62. #{{{  escape not(O or [) -> critical
  63. /^ *\(alias ([^ ]+) \( C-\[ "[^O[](.*) \)\) *$/ {
  64.    critical=$5
  65. }
  66. #}}}
  67. #{{{  esc [ M == mouse sequence -> critical
  68. /^ *\(alias ([^ ]+) \( C-\[ "\[ "M(.*) \)\) *$/ {
  69.    critical=$6
  70. }
  71. #}}}
  72. #{{{  escape C-.         -> critical
  73. /^ *\(alias ([^ ]+) \( C-\[ C-.(.*) \)\) *$/ {
  74.    critical=$5
  75. }
  76. #}}}
  77. #{{{  C-.                -> critical
  78. /^ *\(alias ([^ ]+) \( C-[ABCDEFGHIJKLMNOPQRSTUVWXYZ@_\^].* \)\) *$/ {
  79.    critical=$4
  80. }
  81. #}}}
  82. critical!="" {
  83. #   if (used[$2])
  84. #      print("skipping "current_term" \t"critical":\t"$0)
  85.    next
  86. }
  87. #}}}
  88. #{{{  store valid aliases
  89. { if (used[$2]) term_data=term_data $0 "\n" }
  90. #}}}
  91. END {
  92. #   {{{  print em-term-list file
  93.    print("; This file is generated by make(1), listing known terminals") >"em-term-list"
  94.    printf("(") >"em-term-list"
  95.    for ( i in terminal_leader )
  96.       if (i!="\n\n")
  97.          printf(" %s",terminal_leader[i]) >"em-term-list"
  98.    printf(" )\n") >"em-term-list"
  99. #   }}}
  100. #   {{{  print em-term-alias file
  101.    print("; This file is generated by autoalias(1), listing keys for known terminals") >"em-term-alias"
  102.    for ( i in terminal_leader )
  103.       if (i!="\n\n") {
  104.          printf("{{{  terminal %s%s\n",terminal_leader[i],terminal_group[i]) >"em-term-alias"
  105.          printf("(terminal (%s)\n%s)\n",terminal_leader[i],i) >"em-term-alias"
  106.          if (terminal_group[i]!="")
  107.             printf("(termalias %s (%s ))\n",terminal_leader[i],terminal_group[i]) >"em-term-alias"
  108.          printf("}}}\n") >"em-term-alias"
  109.       }
  110. #   }}}
  111. }
  112.